package org.elephantt.webby;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletInputStream;
import javax.servlet.RequestDispatcher;
import java.util.Enumeration;
import java.util.Map;
import java.util.Locale;
import java.util.HashMap;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.io.BufferedReader;
import java.security.Principal;

/**
 * Trivial mock request. Very incomplete right now.
 *
 * TODO: someone else has done this I'm sure... any good candidates?
 */
class MockRequest implements HttpServletRequest {
  private String requestURI;
  private String method;
  private Map<String, String> parameters = new HashMap<String, String>(); // TODO: only supports a single value for a key right now
  private Map<String, String> headers = new HashMap<String, String>();

  public Object getAttribute(String name) {
    throw new NotImplementedException();
  }

  public Enumeration getAttributeNames() {
    throw new NotImplementedException();
  }

  public String getCharacterEncoding() {
    throw new NotImplementedException();
  }

  public void setCharacterEncoding(String env) throws UnsupportedEncodingException {
    throw new NotImplementedException();
  }

  public int getContentLength() {
    throw new NotImplementedException();
  }

  public String getContentType() {
    throw new NotImplementedException();
  }

  public ServletInputStream getInputStream() throws IOException {
    throw new NotImplementedException();
  }

  public void setParameter(String name, String value) {
    parameters.put(name, value);
  }

  public String getParameter(String name) {
    return parameters.get(name);
  }

  public Enumeration getParameterNames() {
    throw new NotImplementedException();
  }

  public String[] getParameterValues(String name) {
    throw new NotImplementedException();
  }

  public Map getParameterMap() {
    throw new NotImplementedException();
  }

  public String getProtocol() {
    throw new NotImplementedException();
  }

  public String getScheme() {
    throw new NotImplementedException();
  }

  public String getServerName() {
    throw new NotImplementedException();
  }

  public int getServerPort() {
    throw new NotImplementedException();
  }

  public BufferedReader getReader() throws IOException {
    throw new NotImplementedException();
  }

  public String getRemoteAddr() {
    throw new NotImplementedException();
  }

  public String getRemoteHost() {
    throw new NotImplementedException();
  }

  public void setAttribute(String name, Object o) {
throw new NotImplementedException();
  }

  public void removeAttribute(String name) {
throw new NotImplementedException();
  }

  public Locale getLocale() {
    throw new NotImplementedException();
  }

  public Enumeration getLocales() {
    throw new NotImplementedException();
  }

  public boolean isSecure() {
    throw new NotImplementedException();
  }

  public RequestDispatcher getRequestDispatcher(String path) {
    throw new NotImplementedException();
  }

  public String getRealPath(String path) {
    throw new NotImplementedException();
  }

  public int getRemotePort() {
    throw new NotImplementedException();
  }

  public String getLocalName() {
    throw new NotImplementedException();
  }

  public String getLocalAddr() {
    throw new NotImplementedException();
  }

  public int getLocalPort() {
    throw new NotImplementedException();
  }

  public String getAuthType() {
    throw new NotImplementedException();
  }

  public Cookie[] getCookies() {
    throw new NotImplementedException();
  }

  public long getDateHeader(String name) {
    throw new NotImplementedException();
  }


  public String getHeader(String name) {
    return headers.get(name);
  }

  public Enumeration getHeaders(String name) {
    throw new NotImplementedException();
  }

  public Enumeration getHeaderNames() {
    throw new NotImplementedException();
  }

  public int getIntHeader(String name) {
    return Integer.parseInt(getHeader(name));
  }

  public void setHeader(String name, String value) {
    headers.put(name, value);
  }

  public String getMethod() {
    return method;
  }

  public void setMethod(String method) {
    this.method = method;
  }

  public String getPathInfo() {
    throw new NotImplementedException();
  }

  public String getPathTranslated() {
    throw new NotImplementedException();
  }

  public String getContextPath() {
    throw new NotImplementedException();
  }

  public String getQueryString() {
    throw new NotImplementedException();
  }

  public String getRemoteUser() {
    throw new NotImplementedException();
  }

  public boolean isUserInRole(String role) {
    throw new NotImplementedException();
  }

  public Principal getUserPrincipal() {
    throw new NotImplementedException();
  }

  public String getRequestedSessionId() {
    throw new NotImplementedException();
  }

  public String getRequestURI() {
    return requestURI;
  }

  public void setRequestURI(String requestURI) {
    this.requestURI = requestURI;
  }

  public StringBuffer getRequestURL() {
    throw new NotImplementedException();
  }

  public String getServletPath() {
    throw new NotImplementedException();
  }

  public HttpSession getSession(boolean create) {
    throw new NotImplementedException();
  }

  public HttpSession getSession() {
    throw new NotImplementedException();
  }

  public boolean isRequestedSessionIdValid() {
    throw new NotImplementedException();
  }

  public boolean isRequestedSessionIdFromCookie() {
    throw new NotImplementedException();
  }

  public boolean isRequestedSessionIdFromURL() {
    throw new NotImplementedException();
  }

  public boolean isRequestedSessionIdFromUrl() {
    throw new NotImplementedException();
  }
}